#include <_sql.au3>
#include <array.au3>
$var="none"
$FilePath = "C:\Program Files\Orion762\DEMO74\"
$db_adodb = _SQL_Startup()
$ret = _SQL_ParadoxConnect($db_adodb, $FilePath,$FilePath)
;$ret = _SQL_ParadoxJetConnect($db_adodb, $FilePath,$FilePath)

Func _SQL_ParadoxJetConnect($ADODBHandle = -1, $sFilePath1 = "",$Dir="")
    $SQLErr = ""
    If $ADODBHandle = -1 Then $ADODBHandle = $SQL_LastConnection

    If Not IsObj($ADODBHandle) Then
        $SQLErr = "Invalid ADODB.Connection object, use _SQL_Startup()"
        Return SetError($SQL_ERROR, 0, $SQL_ERROR)
    EndIf
    ;
    $ADODBHandle.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&$sFilePath1&";Extended Properties=Paradox 5.x;")
    If @error Then
        $SQLErr = "Connection Error"
        Return SetError($SQL_ERROR, 0, $SQL_ERROR)
    EndIf

    Return SetError($SQL_OK, 0, $SQL_OK)

EndFunc

Func _SQL_ParadoxConnect($ADODBHandle = -1, $sFilePath1 = "",$Dir="")
    $SQLErr = ""
    If $ADODBHandle = -1 Then $ADODBHandle = $SQL_LastConnection

    If Not IsObj($ADODBHandle) Then
        $SQLErr = "Invalid ADODB.Connection object, use _SQL_Startup()"
        Return SetError($SQL_ERROR, 0, $SQL_ERROR)
    EndIf

    $ADODBHandle.Open("Driver={Microsoft Paradox Driver (*.db )};DriverID=538;Fil=Paradox 5.X;DefaultDir="&$Dir&";Dbq=" & $sFilePath1 & ";CollatingSequence=ASCII;")
    If @error Then
        $SQLErr = "Connection Error"
        Return SetError($SQL_ERROR, 0, $SQL_ERROR)
    EndIf

    Return SetError($SQL_OK, 0, $SQL_OK)

EndFunc

;If $ret = $SQL_OK Then
;	Local $aResult, $iRows, $iColumns
;    $vQuery = "DELETE  FROM Plist WHERE ID=26 "
;    _SQL_Execute($db_adodb, $vQuery)
;	MsgBox(48,"Connect","Delete ОК")
    
;Else
;    MsgBox(48,"Error","!")
;EndIf


If $ret = $SQL_OK Then
    Local $aResult, $iRows, $iColumns
    $vQuery = "SELECT * FROM PMark"
    _SQL_GetTable2D($db_adodb, $vQuery, $aResult, $iRows, $iColumns)
    _ArrayDisplay($aResult)
    _SQL_Close($db_adodb)

	
Else
    MsgBox(48,"Error","!")
EndIf
